	//global vars
	var slides_slideIsOpen = false;
	$(document).ready(function() {
	
	
	// Add an onClick behavior to elements with class .item.select
	$("a.slide").live('click', function(e){
		e.preventDefault();
		$(this).addClass("active");
		var slides_productClicked = $(this).parent(),
			slides_alreadyOpenProduct = $('.item.item-expanded'),
			slides_productID = $(this).attr('href').replace('#', '');
			
		if($.browser.safari){ bodyelem = $("body") } else{ bodyelem = $("html") }
			
		window.location.hash = slides_productID;		
		if(slides_slideIsOpen) {
			if (slides_productClicked.hasClass("item-expanded")) {
				// The item we're clicking is already open, so all we need to do is close this single item.
				slides_productClicked.removeClass("item-expanded");
				slides_productClicked.find(".product-detail-expanded").removeClass("product-detail-expanded").slideToggle(800);
				slides_productClicked.find(".product-spacer-expanded").removeClass("product-spacer-expanded").slideToggle(800, function() {
					slides_slideIsOpen = false;
				});
			}
			else {
				//close other slides
				slides_alreadyOpenProduct.removeClass("item-expanded");
				slides_alreadyOpenProduct.find(".product-detail-expanded").removeClass("product-detail-expanded").slideToggle(800);
				slides_alreadyOpenProduct.find(".product-spacer-expanded").removeClass("product-spacer-expanded").slideToggle(800, function() {
					//scroll page
					var slides_productOffsetTop = slides_productClicked.offset().top,
						slides_currentOffest = bodyelem.scrollTop();
					if((slides_currentOffest - slides_productOffsetTop) == 0 ) {
						var slides_scrollDuration = 800;
					} else {
						var slides_scrollDuration = 800;
					}
					bodyelem.animate({'scrollTop': slides_productOffsetTop}, slides_scrollDuration, function() {
						//open new slide
						slides_productClicked.addClass("item-expanded");
						slides_productClicked.find(".product-detail").addClass("product-detail-expanded").slideToggle(500);
						slides_productClicked.find(".product-spacer").addClass("product-spacer-expanded").slideToggle(500);
					})
				});
			}
		} else if(!slides_slideIsOpen) {
			//scroll page
			var slides_productOffsetTop = slides_productClicked.offset().top,
				slides_currentOffest = bodyelem.scrollTop();
			if((slides_currentOffest - slides_productOffsetTop) == 0 ) {
				var slides_scrollDuration = 800;
			} else {
				var slides_scrollDuration = 800;
			}
			bodyelem.animate({'scrollTop': slides_productOffsetTop}, slides_scrollDuration, function() {
				//open new slide
				slides_productClicked.addClass("item-expanded");
				slides_productClicked.find(".product-detail").addClass("product-detail-expanded").slideToggle(500);
				slides_productClicked.find(".product-spacer").addClass("product-spacer-expanded").slideToggle(500, function() {
					slides_slideIsOpen = true;
				});
				
			})
		}
			slides_productClicked.find('.product-detail').empty().html('<img src="ajax-loader.gif" />');
			slides_productClicked.find('.product-detail').load('product.php',function(){
		});		
	});
	
	//function for product close button
	$('.product-detail .close').live('click', function() {
		var slides_slideToClose = $('.item.item-expanded');
		slides_slideToClose.removeClass("item-expanded");
		slides_slideToClose.find(".product-detail-expanded").removeClass("product-detail-expanded").slideToggle(500);
		slides_slideToClose.find(".product-spacer-expanded").removeClass("product-spacer-expanded").slideToggle(500, function() {
			slides_slideIsOpen = false;
		});
	});		

	
	$(document).ready(function(){
		$(".item").live('mouseenter', function () {
			$(this).addClass("click_active");
		});
		$(".item").live('mouseleave', function () {
			$(this).removeClass("click_active");
		});	
		
		$('a.champ').click(function(){
			$('.products-grid').find('.item').each(function(){ 
					if($(this).attr('data-type')=='champ'){
						$(this).hide('fast', function(){
														
							
						});
					}
				});	
								
		});	
	});
});